package com.th.controller;

import com.th.Service.GoodsService;
import com.th.Service.SupplierService;
import com.th.pojo.Supplier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;
import java.util.List;

@Controller
public class TransitionController {

    @Autowired
    GoodsService goodsService;

    @Autowired
    SupplierService supplierService;

    @RequestMapping("/tologin")
    public String login(){
        return "login";
    }

    @RequestMapping("/authc/index")
    public String index(){
        return "authc/index";
    }

    @RequestMapping("/authc/welcome")
    public String welcome(Model model){
        Integer sumStock = goodsService.selectSumStock();
        model.addAttribute("time", new Date());
        model.addAttribute("sumStock", sumStock);
        return "authc/welcome";
    }

    @RequestMapping("/authc/goods-add")
    public String goodsAdd(Model model){
        List<Supplier> supplierList = supplierService.list();
        model.addAttribute("supplierList", supplierList);
        return "authc/goods-add";
    }

    @RequestMapping("/authc/goods-edit")
    public String goodsEdit(){
        return "authc/goods-edit";
    }

    @RequestMapping("/authc/supplier-add")
    public String supplierAdd(){
        return "authc/supplier-add";
    }
}
